package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import io.User.Gender;

public class ObjectInputStreamDemo {

	public static void main(String[] args) throws Exception, IOException {
		ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("user.pfzhang"));
		User user =  new User("哈哈农", 33,Gender.Male);
		objectOutputStream.writeObject(user);
		
		ObjectInputStream inputStream = new ObjectInputStream(new FileInputStream("user.pfzhang"));
		User user1 = (User)inputStream.readObject();
		 System.out.println(user1.Name + ";" + user1.Age + "," + user.getGender());
		 
	}
}
